home *** CD-ROM | disk | FTP | other *** search
/ Univers Interactif 3 / INTERACTIF.BIN / pc / planeten / internet / macslip2.6up / MacSLIP Folder / Netblazer.script < prev    next >
Text File  |  1995-01-11  |  7KB  |  291 lines

  1. #
  2. # Netblazer.script
  3. #
  4. # Script for a Netblazer terminal server
  5. # You may need to modify it to work with your particular configuration.
  6. #
  7. # This script is designed to dial a Hayes compatible modem.
  8. #
  9. # The first time this script runs, it will prompt for your username,
  10. # password, and phone number to dial. These settings will be saved
  11. # for subequent connections.
  12. #
  13. # Using default settings, the modem will be initialized before this script
  14. # starts running. Make sure the "Init modem when connecting" option
  15. # is set in the "Modem" menu and that you have made an appropriate
  16. # modem selection.
  17. #
  18. ignore var busygo
  19.  
  20. # If user is not defined, ask for it.
  21. ifdef user goto skipuser
  22. message ""
  23. message "\bEnter your login username."
  24. ask var
  25. define user "$var"
  26. label skipuser
  27.  
  28. # if password is not defined, ask for it
  29. ifdef password goto skippass
  30. message "Will login to SLIP server as $user.\n\bPassword:"
  31. askp var
  32. define /h password "$var"
  33. label skippass
  34.  
  35. # if phone is not defined, ask for it
  36. ifdef phone goto skipphone
  37. message "\bEnter the phone number to dial"
  38. ask var
  39. define phone "$var"
  40. label skipphone
  41.  
  42. # Let the user know we're starting up
  43. label startup
  44. message "Script starting..."
  45. # Setup action handlers
  46. on restart goto restart
  47. on abort goto abort
  48.  
  49. # Dial the phone and wait for the terminal server to send its login
  50. # banner. Some areas support using *70 as a dialing prefix to suppress
  51. # call-waiting tones which will probably cause your modem
  52. # to lose the connection. Some terminal servers may require you to
  53. # autobaud before they will respond. Allow enough time for the modem
  54. # handshake to complete.
  55.  
  56. label dial
  57.  
  58. ifdef INITMODEM goto skipwarn
  59. beep
  60. message "\bYou should select a modem using Configure"
  61. label skipwarn
  62.  
  63. message "Dialing $phone..."
  64. flush
  65. on abort goto hangupabort
  66. send "ATDT $phone\r"
  67. {
  68.     ifmatch "name:" break
  69.     ifmatch "Login:" break
  70.     ifmatch "login:" break
  71.     ifmatch "NO DIALTONE" goto nodialtone
  72.     ifmatch "NO DIAL TONE" goto nodialtone
  73.     ifmatch "BUSY" goto phonebusy
  74.     ifmatch "NO CARRIER" goto nocarrier
  75.     iftime 1:15 goto dialtimeout
  76. }
  77.  
  78. # Log into the SLIP server. Try three times to send the username. Use
  79. # counter #1 to count the number of login attempts.
  80.  
  81. setcount 1 0
  82. label login
  83. ifcountgt 1 3 goto cantlogin
  84. message "Logging in as $user..."
  85. setcount 0 0
  86. label user
  87. flush
  88. ifcountgt 0 3 goto baduser
  89. send "$user\r"
  90. {
  91.     ifmatch "Password:" break
  92.     ifmatch "password:" break
  93.     ifmatch "Username:" goto user
  94.     ifmatch "login:" goto user
  95.     ifmatch "Login:" goto user
  96.     iftime 10 goto baduser
  97. }
  98.  
  99. # Send the password and wait for the prompt. If we see the
  100. # username prompt again, then we didn't get logged in so try again.
  101.  
  102. message "Sending password..."
  103. flush
  104. send "$password\r"
  105. {
  106.     ifmatch ">" goto setslip
  107.     ifmatch "%" goto setslip
  108.     ifmatch "Access denied" goto accessdenied
  109.     ifmatch "incorrect" goto accessdenied
  110.     iftime 10 goto cantlogin
  111. }
  112.  
  113. # If the login attempt fails, we land here.
  114.  
  115. label accessdenied
  116. {
  117.     ifmatch "Username:" goto login
  118.     ifmatch "Login:" goto login
  119.     ifmatch "login:" goto login
  120.     ifmatch "NO CARRIER" goto cantlogin
  121.     iftime 10 goto cantlogin
  122. }
  123.  
  124. # Enable SLIP.
  125.  
  126. label setslip
  127. message "Enabling SLIP mode on server..."
  128. flush
  129. send "slip\r"
  130. {
  131.     ifmatch "connected" break
  132.     ifmatch "Connected" break
  133.     iftime 10 goto cantstartslip
  134. }
  135.  
  136. # All done.  Send message to alert the user, flush the junk out of the
  137. # receive buffer, and return success.
  138.  
  139. message "Script complete"
  140. flush
  141. return 1
  142.  
  143. # Error handlers.
  144.  
  145. label abort
  146. beep
  147. message "\bCommand-. seen or Cancel button clicked."
  148. goto aborted
  149.  
  150. label hangupabort
  151. beep
  152. message "\bCommand-. seen or Cancel button clicked."
  153. goto hangup
  154.  
  155. label cantfindmodem
  156. beep
  157. message "\bThe modem didn't respond to attention"
  158. message "\bbsignal.  Check modem and cabling."
  159. goto aborted
  160.  
  161. label cantinitmodem
  162. beep
  163. message "\bThe modem didn't respond to initialization"
  164. message "\bstring.  Check the modem."
  165. goto aborted
  166.  
  167. label nodialtone
  168. beep
  169. message "\bThe modem could not detect a dialtone."
  170. message "\bCheck the phone line."
  171. goto aborted
  172.  
  173. label phonebusy
  174. flush
  175. message "\bThe number $phone is busy."
  176. if $busygo eq "go" goto redial
  177. on restart goto busygo
  178. beep
  179. message "\bClick "Restart" to keep trying, "OK" to quit."
  180. ask junk
  181. return 0
  182.  
  183. label busygo
  184. on restart goto restart
  185. set busygo "go"
  186. flush
  187. label redial
  188. do syncmodem
  189. goto dial
  190.  
  191. label nocarrier
  192. beep
  193. message "\bThe modem could not establish a connection."
  194. message "\bMake sure there is a modem on the other end."
  195. goto aborted
  196.  
  197. label dialtimeout
  198. message "\bThe modem or SLIP server isn't responding."
  199. message "\bTry dialing manually to make sure the modem"
  200. message "\band SLIP server are OK."
  201. goto aborted
  202.  
  203. label baduser
  204. beep
  205. message "\bThe SLIP server won't accept a username."
  206. message "\bTry dialing manually to make sure the SLIP"
  207. message "\bserver is OK."
  208. goto hangup
  209.  
  210. label cantlogin
  211. beep
  212. message "\bLogin to SLIP server failed, check username"
  213. message "\band password."
  214. goto hangup
  215.  
  216. label cantsetterm
  217. beep
  218. message "\bCan't set terminal line for SLIP operation."
  219. goto hangup
  220.  
  221. label cantstartslip
  222. beep
  223. message "\bCan't put server into SLIP mode."
  224. goto hangup
  225.  
  226. # General back-end for bailing out.
  227.  
  228. label hangup
  229. do disconnect
  230. # fallthrough into aborted
  231.  
  232. label aborted
  233. message "\bScript aborted!"
  234. message "\bClick "OK" to quit, "Restart" to retry."
  235. # This activates the OK button.
  236. ask junk
  237. flush
  238. return 0
  239.  
  240. # Restart procedure.
  241. # This label is entered when you click the restart button in the
  242. # connection dialog. We try to force the modem to hang up, then we go back
  243. # to the start of the script.
  244.  
  245. label restart
  246. do disconnect
  247. message "\bScript restarted."
  248. goto startup
  249.  
  250. # Disconnect procedure. The "disconect" procedure is called by MacSLIP
  251. # when the "Disconnect" button is clicked. This procedure escapes the
  252. # modem into command mode and hangs up the phone. The +++ escape sequence
  253. # is surrounded by delays that some modems require.
  254.  
  255. label disconnect
  256. send "\d\d+++\d\dATH\r\d\d"
  257. do syncmodem
  258. return 1
  259.  
  260. # Alternate disconnect procedure for modems that drop into command mode
  261. # when DTR is dropped. You may want to try this alternate disconnect
  262. # procedure if the one above doesn't work for your modem. Just swap the
  263. # labels to use this one instead of the one above.
  264.  
  265. label disconnect2
  266. dtr off
  267. delay 3
  268. send "ATH\r"
  269. dtr on
  270. flush
  271. return 1
  272.  
  273. # Attempt to sync up with the modem, but don't wait forever.
  274. label syncmodem
  275. setcount 4 0
  276. flush
  277. label waitmodem2
  278. ifcountgt 4 2 return
  279. send "AT\r"
  280. {
  281.     ifmatch "OK" break
  282.     iftime 2 goto waitmodem2
  283. }
  284. flush
  285. return
  286.  
  287. # for Emacs
  288. #  Local Variables:
  289. #  tab-width: 4
  290. #  End:
  291.